package com.chinasofti.controller;

import com.chinasofti.service.MeetingroomService;
import com.chinasofti.vo.Meetingroom;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/updateMeetingRoomServlet")
public class UpdateMeetingRoomServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        int roomid = Integer.parseInt(req.getParameter("roomid"));
        int roomnum = Integer.parseInt(req.getParameter("roomnum"));
        int capacity = Integer.parseInt(req.getParameter("capacity"));
        String roomname = req.getParameter("roomname");
        String status = req.getParameter("status");
        String description = req.getParameter("description");
        //    public MeetingRoom(Integer roomid, Integer roomnum, Integer capacity, String roomname,
        //    String status, String description) {
        Meetingroom room = new Meetingroom(roomid,roomnum,capacity,roomname,status,description);
        System.out.println("room = " + room);
        MeetingroomService service = new MeetingroomService();
        service.updateMeetingRoom(room);
        req.getRequestDispatcher("viewAllMeetingsServlet").forward(req,resp);
    }
}